package com.caregiver.watch.common.enums;

import lombok.Getter;

/***
 * @Title SendSmsCode
 * @Description 发送短信验证码枚举
 * @Author YanDeChao
 * @Create 2024/3/8
 */
@Getter
public enum SendSmsCodeEnum {
    /**
     * 客户手机号
     */
    CUSTOMER_PHONE(0, "PHONE", "更换手机号", 5L),
    /**
     * 登录
     */
    CUSTOMER_LOGIN(1, "CUSTOMER_LOGIN", "登录", 5L),
    /**
     * 注册
     */
    CUSTOMER_REGISTER(2, "CUSTOMER_REGISTER", "注册", 30L),
    /**
     * 重置密码
     */
    CUSTOMER_RESET_PWD(3, "CUSTOMER_RESET_PWD", "重置密码", 5L);

    private final Integer code;

    private final String key;

    private final String operate;
    /**
     * 有效期(分钟)
     */
    private final Long expire;

    private SendSmsCodeEnum(Integer code, String key, String operate, Long expire) {
        this.code = code;
        this.key = key;
        this.operate = operate;
        this.expire = expire;
    }

    public static SendSmsCodeEnum getKeyByCode(Integer code) {
        for (SendSmsCodeEnum codeEnum : values()) {
            if (codeEnum.getCode().equals(code)) {
                return codeEnum;
            }
        }
        return SendSmsCodeEnum.CUSTOMER_PHONE;
    }
}
